<template>
    <view class="content">
		<view class="_label_top">
			<image class="_btn_top" src="../../static/img/kjg.png"></image>
			<label class="_lab_top">{{itext}}</label>
		</view>
		<view  class="_bg_middle">
			<m-list-scroll :listData="listData" @click="generate" :uid="id"/>
		</view>
		<cmd-bottom-nav @click="tapNav"  border-color="#BC1BBE" background-color="#BC1BBE" font-color="#fff" active-font-color="#fff" current="1"></cmd-bottom-nav>
    </view>
</template>

<script>
	import cmdBottomNav from "@/components/cmd-bottom-nav/cmd-bottom-nav.vue"
	import mbtn from "@/components/m-btn-type/m-btn.vue"
	import mtabbar from "@/components/m-tabbar/m-tabbar.vue"
	import mBtnCs from '@/components/m-btn/m-btn-cs.vue'
	import mListScroll from '@/components/m-list/m-list-scroll.vue'
	import mutil from '../../static/js/util.js'
	import comm  from '../../common/helpers.js'
    export default {
		components:{mbtn,mtabbar,cmdBottomNav,mBtnCs,mListScroll},
		data(){
			return{
				itext:'咨询下面任意一个塔罗师(左右滑动)',
				listData:[],
				id:-1
			}
		},
        onLoad() {
			this.getConsList()
			comm.login()
        },
		onShow() {
			this.id = uni.getStorageSync('uid')
			// console.log(this.id)
		},
		methods:{
			tapNav(e){
				let that = this
				let path = e.item.pagePath
				uni.switchTab({
					url:path,
					success: (res) => {
						clearInterval(that.timer)
					},
					complete: (com) => {
					}
				})
			},
			getConsList(){
				let gdata=uni.getStorageSync('globalData')
				uni.request({
					url: comm.websiteUrl+'?s=v1/getconsList/',
					method: 'POST',
					data: {
						'mid':gdata.data.openid
					},
					success: res => {
						if (res.data.code == 200) {
							this.listData = res.data.data
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			generate(e){
				let gdata=uni.getStorageSync('globalData')
				// 先生成订单，然后返回订单信息，如果订单创建成功，跳转支付页面
				// 生成订单
				uni.request({
					url: comm.websiteUrl+'?s=v1/paycon/',
					method: 'POST',
					data: {
						//代表占卜师
						'title':e.title,
						// 代表所属分类
						'id':e.id,
						// 代表用户openid
						'mid':gdata.data.openid
					},
					success: res => {
						// console.log(res)
						/**
						 * order_no：订单号
						 * mid：用户openid
						 * rule：订单类型及标题
						 * mo：所属小模块
						 * rmod：所属大模块
						 */
						if(res.data.code == 200){
							uni.navigateTo({
								url:'/pages/user/user_pay_cons?order_no='+res.data.data.order_no+'&mid='+gdata.data.openid+'&rule='+e.title+"&uid="+e.id,
								success: (res) => {
								}
							})
						}else{
							uni.showModal({
								title:'警告',
								content:'订单创建失败!!!',
								showCancel:false,
								success:function(res){
								}
							})
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
		
    }
</script>

<style lang="scss">
	.content{
		width:100%;
		height:100%;
		position:absolute;
		padding: 0upx;
		background-image: url('https://zhanbu.nomeis.cn/upload/page_resource/bg3.png');
		background-repeat: no-repeat;
		background-size: 100% 95%;
		
		._bg{
			width: 100%;
			height:90%;
			vertical-align: top;
			top: 0;
			right: 0;
			position:absolute;
			vertical-align: middle;
		}
		
		._lbtn{
			width:330rpx;
			margin:auto;
			position:relative;
			display:inline-block;
			z-index:12;
			
			._outer{
				width: 100%;
			}
		}
		
		._label_top{
			display:flex;
			width:100%;
			top:25upx;
			height:auto;
			position:relative;
			justify-content:center;

			._btn_top{
				height:185upx;
				width: 50%;
			}
			
			._lab_top{
				z-index:3;
				color:white;
				width:30%;
				text-align:center;
				justify-content:center;
				align-items:center;
				position:absolute;
				display:flex;
				margin:auto;
				height:100%;
			}
		}
		
		._bg_middle{
			width:100%;
			height:100%;
			position:absolute;
			z-index:7;
			margin:auto;
			justify-content:center;
			vertical-align:middle;
			align-items:center;
			display:flex;
			
			m-list-scroll{
				width: 90%;
				
				view{
					.scroll-view_H{
						height: 570upx;
						
						.scroll-view-item_H{
							width: 535upx;
						}
					}
				}
				._sch{
					._scrith{
						._content{
							height: 237upx;
						}
					}
				}
			}
		}
	}
</style>
